var voteContent = {

}

var voteItem = {
	'text':''
}

var newVue = new Vue({
	el: '#main',
	data: {
		headerData:{
			'titleColor':'#555a5e',
			'title':'创建单选投票',
			'icon':false,
			'iconColor':'white',
			'titleIcon':'fa-plus-circle'
		},
		check:0,
		checkItem:[],
		voteContent: {
			desp:'',
			totalNumber:0,
			voteUserIds: '',
			endTime:'',
			voteItem:[]
		},
		title: null
	},
	mounted: function() {
		this.init();
		this.addItem();
		this.addItem();
	},
	methods: {
		init: function() {
			var checkType = util.getUrlParam("view");
			this.check = checkType;
			if(checkType == 0) {
				this.headerData.title = '创建单选投票';
			} else {
				this.headerData.title = '创建多选投票';
			}
		},
		addItem: function() {
			this.checkItem.push({
				'text':''
			});
		},
		releaseItem: function(index) {
			console.info(index);
			this.checkItem.splice(index,1);
		},
		create: function() {
			for(var i=0;i<this.checkItem.length;i++) {
				this.voteContent.voteItem.push({
					voteId: i,
					voteItemDesp: this.checkItem[i].text,
					voteNumber:0
				})
			}
			console.info(JSON.stringify(this.voteContent,"\t"))
			var that = this;
			util.tokenJsonPost('https://www.maksdu.com/app/post/vote/create?title='+that.title,JSON.stringify(this.voteContent),function(data) {
				if(data.code == 200) {
					window.location.replace("votelist.html");
				}
			})
		}
	}
});